<?php

namespace api\game\controller;

use Aaa\game\model\GameModel;

class AdminGoodsTypeController extends \Aaa\game\controller\AdminGoodsTypeController {

    protected function init() {
        $model = new GameModel;
        $this->baseField = [
            [
                'field' => 'id',
                'name' => 'ID',
            ],
            [
                'field' => 'name',
                'name' => '名称',
            ],
            [
                'field' => 'game_id',
                'name' => '游戏',
                'type' => 'hidden',
            ],
            [
                'field' => 'built_in_type',
                'name' => '内置类型',
                'type' => 'radio',
                'options' => [
                    ['name' => '账号', 'value' => 'accountTransaction'],
                    ['name' => '金币', 'value' => 'gameCurrencyTransaction'],
                    ['name' => '其他', 'value' => '',]
                ],
                'remark' => '账号：发布商品需要额外提交账号字段（账号、密码等信息）<br>金币：需要提交金币数量',
            ],
            [
                'field' => 'need_review',
                'name' => '需要审核',
                'type' => 'switch',
                'options' => ['需要', '不需要'],
                'remark' => '新发布的商品是否需要管理员审核',
            ],
            [
                'field' => 'delivery_type',
                'name' => '发货类型',
                'type' => 'checkbox',
                'options' => $model->deliveryType,
            ],
            [
                'field' => 'sell_need_compensation',
                'name' => '发布商品包赔服务',
                'type' => 'switch',
                'remark' => '发布商品是否允许购买包赔服务',
            ],
            [
                'field' => 'sell_need_compensation_default_id',
                'name' => '发布商品默认包赔服务',
                'type' => 'select',
                'options' => [
                    ['name' => '无', 'value' => 0],
                ],
                'optionsSource' => [
                    'table' => 'goods_compensation',
                    'nameField' => 'name',
                    'valueField' => 'id',
                ],
            ],
            [
                'field' => 'buy_need_compensation',
                'name' => '购买商品包赔服务',
                'type' => 'switch',
                'remark' => '购买商品是否允许购买包赔服务（发布商品选择了包赔，购买商品不需要选择）',
            ],
            [
                'field' => 'buy_need_compensation_default_id',
                'name' => '购买商品默认包赔服务',
                'type' => 'select',
                'options' => [
                    ['name' => '无', 'value' => 0],
                ],
                'optionsSource' => [
                    'table' => 'goods_compensation',
                    'nameField' => 'name',
                    'valueField' => 'id',
                ],
            ],
            [
                'field' => 'multiple',
                'name' => '商品数量',
                'type' => 'radio',
                'options' => [['name' => '单件', 'value' => 0], ['name' => '多件', 'value' => 1,]],
            ],
            [
                'field' => 'unit',
                'name' => '商品单位',
                'remark' => '账号类型留空，金币可设置：金币、万金币等',
            ],
            [
                'field' => 'fee_pct',
                'name' => '手续费',
                'remark' => '订单结束后，在卖家收到的金额里面扣除的百分比',
            ],
            [
                'field' => 'list_order',
                'name' => '排序',
            ],
        ];
    }


    protected function beforeIndex() {
        $this->actionField = ['id', 'name', 'delivery_type', 'need_review', 'multiple', 'unit', 'fee_pct', 'list_order',];
    }

    protected function beforeAdd() {

    }

    protected function beforeEdit() {
        $this->beforeAdd();
    }


}
